package manager.cms.controller;
import common.PageView;
import common.SnowflakeIdWorker;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import manager.cms.service.CmsContentService;
import manager.cms.vo.CmsContentCatVO;
import manager.cms.vo.CmsContentVO;
import manager.config.RequiredPermission;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping(value = {"/admin/manager"})
@Api(value = "品牌管理模块")
public class CmsContentAdminController {
     @Autowired
     private CmsContentService cmsContentService;
    /**
     * 分页查询分类信息
     * @return
     */
    @RequiredPermission(module="cmsCategory",code = "listPage")
    @RequestMapping(value = "/cms/category/content/page/list", method = RequestMethod.POST)
    @ApiOperation(notes = "查询首页cms分类信息", value = "get categories info")
    public PageView<List<CmsContentCatVO>> getCmsContentCatByPage(@RequestBody CmsContentCatVO cmsContentCatVO){
         return  cmsContentService.getCmsContentCatByPage(cmsContentCatVO);
    }
    /**
     * 不分页查询分类信息
     */
    @RequiredPermission(module="cmsCategory",code = "list")
    @RequestMapping(value = "/cms/category/content/list", method = RequestMethod.POST)
    @ApiOperation(notes = "查询首页cms分类信息", value = "get categories info")
    public List<CmsContentCatVO> getCmsContentCat(@RequestBody CmsContentCatVO cmsContentCatVO){
         return cmsContentService.getCmsContentCat(cmsContentCatVO);
    }
    /**
     * 分页查询内容
     */
    @RequiredPermission(module="cmsContent",code = "pageList")
    @RequestMapping(value = "/cms/content/page/list", method = RequestMethod.POST)
    @ApiOperation(notes = "分页查询首页cms信息", value = "get categories info")
    public PageView<List<CmsContentVO>> getCmsContentByPage(@RequestBody CmsContentVO cmsContentVO){
         return cmsContentService.getCmsContentByPage(cmsContentVO);
    }
    /**
     * 不分页查询内容
     */
    @RequiredPermission(module="cmsContent",code = "list")
    @RequestMapping(value = "/cms/content/list", method = RequestMethod.POST)
    @ApiOperation(notes = "查询首页cms分类信息", value = "get categories info")
    public List<CmsContentVO> getCmsContent(@RequestBody CmsContentVO cmsContentVO){
         return cmsContentService.getCmsContent(cmsContentVO);
    }
    /**
     * 单个新增分类信息
     */
    @RequiredPermission(module="cmsCategory",code = "add")
    @RequestMapping(value = "/cms/category/content/add", method = RequestMethod.POST)
    @ApiOperation(notes = "添加cms分类信息", value = "get categories info")
    public void addCmsContentCan(@RequestBody CmsContentCatVO cmsContentCatVO){
        cmsContentService.addCmsContentCan(cmsContentCatVO);
    }
    /**
     * 批量添加分类信息
     */
    @RequestMapping(value = "/cms/category/content/add/batch", method = RequestMethod.POST)
    @ApiOperation(notes = "批量添加cms分类信息", value = "get categories info")
    @RequiredPermission(module="cmsCategory",code = "addBatch")
    public void addCmsContentCatBatch(@RequestBody List<CmsContentCatVO> cmsContentCatList){
        cmsContentService.addCmsContentCatBatch(cmsContentCatList);
    }
    /**
     * 单个新增内容信息
     */
    @RequestMapping(value = "/cms/content/add", method = RequestMethod.POST)
    @ApiOperation(notes = "添加cms信息", value = "get categories info")
    @RequiredPermission(module="cmsContent",code = "add")
    public void addCmsContent(@RequestBody CmsContentVO cmsContentVO){
        String id=String.valueOf(SnowflakeIdWorker.nextId());
        cmsContentVO.setId(id);
        cmsContentService.addCmsContent(cmsContentVO);
    }
    /**
     * 批量添加内容信息
     */
    @RequestMapping(value = "/cms/content/add/batch", method = RequestMethod.POST)
    @ApiOperation(notes = "批量添加cms信息", value = "get categories info")
    @RequiredPermission(module="cmsContent",code = "addBatch")
    public void addCmsContentBatch(@RequestBody List<CmsContentVO> cmsContentList){
        cmsContentService.addCmsContentBatch(cmsContentList);
    }
    /**
     * 修改分类信息
     */
    @RequiredPermission(module="cmsCategory",code = "update")
    @RequestMapping(value = "/cms/category/content/update", method = RequestMethod.POST)
    @ApiOperation(notes = "修改cms分类想你想", value = "get categories info")
    public void updateCmsContentCan(@RequestBody CmsContentCatVO cmsContentCatVO){
        cmsContentService.updateCmsContentCan(cmsContentCatVO);
    }
    /**
     * 修改内容信息
     */
    @RequiredPermission(module="cmsContent",code = "update")
    @RequestMapping(value = "/cms/content/update", method = RequestMethod.POST)
    @ApiOperation(notes = "修改cms信息", value = "get categories info")
    public void updateCmsContent(@RequestBody CmsContentVO cmsContentVO){
        cmsContentService.updateCmsContent(cmsContentVO);
    }
    /**
     * 删除分类信息
     */
    @RequiredPermission(module="cmsCategory",code = "delete")
    @RequestMapping(value = "/cms/category/content/delete", method = RequestMethod.POST)
    @ApiOperation(notes = "删除cms分类信息", value = "get categories info")
    public void deleteCmsContentCanList(@RequestBody String[] ids){
        cmsContentService.deleteCmsContentCanList(ids);
    }
    /**
     * 删除内容信息
     */
    @RequiredPermission(module="cmsContent",code = "delete")
    @RequestMapping(value = "/cms/content/delete", method = RequestMethod.POST)
    @ApiOperation(notes = "删除cms信息", value = "get categories info")
    public void deleteCmsContentList(@RequestBody String[] ids){
        cmsContentService.deleteCmsContentList(ids);
    }
    @RequestMapping(value = "/cms/async/jdcmsdata", method = RequestMethod.POST)
    @ApiOperation(notes = "同步京东cms信息", value = "get categories info")
    @RequiredPermission(module="cmsCategory",code = "jdcmsdata")
    public void asyncJdCmsData(){
        cmsContentService.asyncJdCmsData();
    }
    @RequestMapping(value = "/cms/async/jdcategory/goods", method = RequestMethod.POST)
    @ApiOperation(notes = "同步京东分类的商品信息", value = "get categories info")
    @RequiredPermission(module="category",code = "asyncJdCategoryGoods")
    public void asyncJdCategoryGoods(@RequestBody Map<String,Object> categoryInfo){
        cmsContentService.asyncJdCategoryGoods(categoryInfo);
    }
    @RequestMapping(value = "/cms/async/jdcategory/templete", method = RequestMethod.POST)
    @ApiOperation(notes = "同步京东分类的商品信息", value = "get categories info")
    @RequiredPermission(module="category",code = "asyncParamsTemplete")
    public void asyncJdCategoryTemplete(@RequestBody Map<String,Object> categoryInfo){
        cmsContentService.asyncJdCategoryTemplete(categoryInfo);
    }

    @RequestMapping(value = "/cms/async/jd/brand", method = RequestMethod.POST)
    @ApiOperation(notes = "同步京东分类的商品信息", value = "get categories info")
    @RequiredPermission(module="category",code = "asyncBrand")
    public void asyncJdBrand(@RequestBody Map<String,Object> categoryInfo){
        cmsContentService.asyncJdBrand(categoryInfo);
    }
}
